<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Dynamic Table</title>

    <!--dynamic table-->
    <link href="/public/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
    <link href="/public/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
    <link rel="stylesheet" href="/public/js/data-tables/DT_bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="/public/js/DataTables-1.10.18/datatables.min.css"/>

    <!--icheck-->
    <link href="/public/js/iCheck/skins/minimal/minimal.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/minimal/purple.css" rel="stylesheet">

    <link href="/public/js/iCheck/skins/square/square.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/square/purple.css" rel="stylesheet">

    <link href="/public/js/iCheck/skins/flat/grey.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/red.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/green.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/blue.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/yellow.css" rel="stylesheet">
    <link href="/public/js/iCheck/skins/flat/purple.css" rel="stylesheet">


    <?php $this->load->view('library/header');?>
</head>

<body class="sticky-header">

<section>

    <?php $this->load->view('library/left');?>

    <!-- main content start-->
    <div class="main-content" >

        <?php $this->load->view('library/top');?>

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                产品列表
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Dashboard</a>
                </li>
                <li>
                    <a href="#">Data Tables</a>
                </li>
                <li class="active"> Dynamic Table </li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-sm-12">
                    <?php $this->load->view('library/search');?>
                    <section class="panel">
                        <div class="panel-body">
                            <div class="slide-toggle">
                                <div class="icheck ">

                                    <?php foreach ($siteweb as $val):?>
                                        <div class="single-row">
                                            <div class="click_box">
                                                <input type="checkbox" name="check" <?php if(strpos($param['prepare_state'],$val['web_id']) == true){ echo 'checked';}?>  value="<?php echo $val['web_id'];?>" data-type="checkbox">
                                                <label><?php echo $val['web_name'];?></label>
                                            </div>
                                        </div>
                                    <?php endforeach;?>
                                </div>
                            </div>
                        </div>
                    </section>
                    <section class="panel">
                        <div class="panel-body">
                            <div class="adv-table">
                                <table class="display table table-bordered table-striped" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="5%" rowspan="2">图片</th>
                                        <th width="6%" rowspan="2">货号</th>
                                        <th colspan="<?php echo $siteweb_is_a;?>">站点销量</th>
                                        <th rowspan="2">总销量</th>
                                    </tr>
                                    <tr>
                                        <?php foreach ($web as $k => $val):?>
                                            <th class="<?php echo $val['web_name'];?>-title"><?php echo $val['web_name'];?></th>
                                        <?php endforeach;?>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php if($goods_list){?>
                                    <?php foreach ($goods_list as $item): ?>
                                        <tr class="gradeX">
                                            <td><img style="width: 60px;" src="<?php echo $item['baby_goods_img'];?>" /></td>
                                            <td class="center hidden-phone">
                                                <?php echo $item['baby_goods_sn'];?><br />
                                            </td>
                                            <?php foreach ($item['web'] as $ke => $val):?>
                                                <td class="<?php echo $ke;?>-cont"  ><?php echo $val;?></td>
                                            <?php endforeach;?>
                                            <td ><?php echo $item['sum'];?></td>
                                        </tr>
                                    <?php endforeach;?>
                                    <?php }?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="row-fluid" >
                                <div class="span6" >
                                    <div class="dataTables_paginate paging_bootstrap pagination" >
                                        <ul >
                                            <?php echo $pages; ?>
                                        </ul >
                                    </div >
                                </div >
                            </div >
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2014 &copy; AdminEx by
        </footer>
        <!--footer section end-->

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">采购数据</h4>
                    </div>

                    <div class="modal-body row">

                    </div>

                </div>
            </div>
        </div>
        <!-- modal -->

    </div>
    <!-- main content end-->
</section>

<?php $this->load->view('library/footer');?>

<script type="text/javascript" src="/public/js/DataTables-1.10.18/datatables.min.js"></script>
<!--icheck -->
<script src="/public/js/iCheck/jquery.icheck.js"></script>
<script src="/public/js/icheck-init.js"></script>
<script src="/public/js/jquery.cookies.js"></script>
<script type="text/javascript">
//     $("body").delegate(".icheckbox_minimal input[name='check']","click",function(){
//        alert(1111)
//        });
    $("input[name='check']").click(function(){
        var prepare_state = $("input[name='prepare_state']").val();
        var web = '';
        var val = $(this).val();
        if($(this).is(':checked') === true){
            web = prepare_state +','+ val;
        }else{
            var arr = prepare_state.split(',');
            
            for(var i=0;i<arr.length; i++)
            {
                if(arr[i] != val && arr[i] != ''){
                    web = web+','+arr[i];
                }
            }        
        }
        $("input[name='prepare_state']").val(web);
        // $(this).is(":checked"){
        //     alert(41)
        // }else{
        //     alert(1)
        // }
        // alert(val)
    })
    // $(".excel_psge").change(function(){
    //     var excel_psge = $('.excel_psge').val();
    //     var href = $('.thisURL').attr('href');
    //     var url = href + '&page='+excel_psge;
    //     $('.thisURL').attr('href',url);
    // })
    // $(function () {
    //     $(".icheck input").on('ifChanged', function(event){
    //         alert(11)
    //         var ischecked = $(this).attr('checked');

    //         var isthnum = Number($('.table thead th:eq(2)').attr('colspan'));

    //         var val = $(this).val();

    //         if (ischecked) {
    //             $('.table thead th:eq(2)').attr('colspan', isthnum + 1);
    //             $.cookie(val, 0, { expires: 7, path: '/' });
    //             $('.' + val + '-title').show();
    //             $('.' + val + '-cont').show();
    //         } else {
    //             $('.table thead th:eq(2)').attr('colspan', isthnum - 1);
    //             $.cookie(val, 1, { expires: 7, path: '/' });
    //             $('.' + val + '-title').hide();
    //             $('.' + val + '-cont').hide();
    //         }
    //     });

    // });

    // $('.val-c-title').click(function () {
    //     var k = $(this).attr('data-k');
    //     $.cookie('order_sort', k, { expires: 7, path: '/' });

    //     location.reload();
    // });


    // $('.mymodal').click(function () {

    //     var id = $(this).attr('data-id');
    //     var sale_time_end = $(this).attr('data-end-time');
    //     var sale_time_tart = $(this).attr('data-st-time');

    //     $.get('<?php echo base_url('product/ajax_sales');?>'+'?pg_id='+id+'&sale_time_end='+sale_time_end+'&sale_time_start='+sale_time_tart, function (data) {
    //         $('#myModal .modal-body').html(data);
    //     }, 'html');
    // });

    // //设置cookie
    // function setCookie(cname, cvalue, exdays) {
    //     var d = new Date();
    //     d.setTime(d.getTime() + (exdays*24*60*60*1000));
    //     var expires = "expires="+d.toUTCString();
    //     document.cookie = cname + "=" + cvalue + ";path=/; " + expires;
    // }
    // //获取cookie
    // function getCookie(cname) {
    //     var name = cname + "=";
    //     var ca = document.cookie.split(';');
    //     for(var i=0; i<ca.length; i++) {
    //         var c = ca[i];
    //         while (c.charAt(0)==' ') c = c.substring(1);
    //         if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    //     }
    //     return "";
    // }
    // //清除cookie
    // function clearCookie(name) {
    //     setCookie(name, "", -1);
    // }
    // function add_cookie(export_goods) {
    //     var cgoods = getCookie('export_goods');
    //     if(export_goods.checked){
    //         setCookie('export_goods', (cgoods ? (cgoods+',') : '')+export_goods.value, 1);
    //     } else {
    //         arr_goods = cgoods.split(',');
    //         for (i in arr_goods) {
    //             if (arr_goods[i] == export_goods.value) {
    //                 arr_goods.shift(i,1);
    //             }
    //         }
    //         setCookie('export_goods', arr_goods.join(','), 1);
    //     }
    // }

    // $(".import-ajax").on("click", function () {

    //     var url = $(this).attr('href');
    //     var goods_sn = $(this).attr('data-sn');

    //     swal({
    //         title: goods_sn,
    //         input: 'select',
    //         inputOptions: <?php echo $siteweb_json; ?>,
    //         showCancelButton: true,
    //         allowOutsideClick: false,
    //         confirmButtonText: 'Submit',
    //         inputPlaceholder: '请选择网站',
    //         inputValidator: function(value) {
    //             if (!value) {
    //                 return '未选择任何网站!';
    //             }
    //         },
    //         preConfirm: function preConfirm(value) {
    //             swal({
    //                 imageUrl: '/public/images/Forrest.gif',
    //                 title: '稍等...',
    //                 allowOutsideClick: false,
    //                 showConfirmButton: false
    //             });
    //             return $.post(url, {web_id: value}, function (data) {
    //                 return data;
    //             },'json');
    //         }
    //     }).then(function (result) {
    //         if (result.value) {
    //             var data = result.value;
    //             swal({
    //                 type: data.status,
    //                 title: data.info
    //             }).then(function(isConfirm) {
    //                 location.reload();
    //             });
    //         }
    //     });

    //     return false;
    // });
</script>

<!--dynamic table-->
<!--<script type="text/javascript" language="javascript" src="/public/js/advanced-datatable/js/jquery.dataTables.js"></script>-->
<!--<script type="text/javascript" src="/public/js/data-tables/DT_bootstrap.js"></script>-->
<!--dynamic table initialization -->
<!--<script src="/public/js/dynamic_table_init.js"></script>-->

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
